var t = require("../../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../../utils/util.js")), a = getApp();

Page({
    data: {
        select: !1,
        is_name: "Auction",
        keyword: "",
        status: "1",
        page: 1,
        current_page: 1,
        last_page: 1,
        is_new: "",
        is_recommend: "",
        auctioneer_id: ""
    },
    onLoad: function(t) {
        t.is_recommend && this.setData({
            is_recommend: t.is_recommend
        }), t.is_new && this.setData({
            is_new: t.is_new
        }), t.status && this.setData({
            status: t.status
        }), this.getSearch();
    },
    goshop: function(t) {
        console.log(t.currentTarget.dataset.id);
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageD/auction/auctioneer-shop/auctioneer_shop/auctioneer_shop?id=" + a
        });
    },
    selectTap: function() {
        this.setData({
            select: !this.data.select
        });
    },
    nametap: function(t) {
        this.setData({
            is_name: t.currentTarget.dataset.name,
            select: !1,
            status: "Auction" == t.currentTarget.dataset.name ? "2" : "1",
            datas: [],
            page: 1,
            current_page: 1,
            last_page: 1
        }), this.getSearch();
    },
    goSearch: function() {
        this.setData({
            page: 1,
            current_page: 1,
            last_page: 1
        }), this.getSearch();
    },
    is_keyword: function(t) {
        var a = t.detail.value;
        this.setData({
            keyword: a,
            page: 1,
            current_page: 1,
            last_page: 1
        }), this.getSearch();
    },
    toGoods: function(t) {
        var a = t.currentTarget.dataset.item.goods_id, e = t.currentTarget.dataset.item.member_id ? t.currentTarget.dataset.item.member_id : t.currentTarget.dataset.item.auctioneer_id;
        wx.navigateTo({
            url: "/packageD/auction/auction/auction_good/auction_good?id=" + a + "&member_id=" + e
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page >= this.data.last_page) wx.showToast({
            title: "没有更多",
            icon: "none",
            duration: 1e3
        }); else {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), this.getSearchMore();
        }
    },
    onShareAppMessage: function() {},
    getSearch: function() {
        var e = this, s = a.getNetAddresss("plugin.auction.api.index.getAuctionData"), n = {
            keyword: e.data.keyword,
            status: this.data.status,
            auc_status: "",
            is_new: "",
            is_recommend: "",
            auctioneer_id: "",
            art: "getSearch",
            page: this.data.page
        };
        a._postNetWork({
            url: s,
            data: n,
            success: function(a) {
                var s = a.data;
                if (1 == s.result) {
                    if (0 == s.data.getSearch.data.length) return 1 == e.data.status ? wx.showToast({
                        title: "没有相关拍品",
                        icon: "none",
                        duration: 1e3
                    }) : 2 == e.data.status && wx.showToast({
                        title: "没有相关拍卖官",
                        icon: "none",
                        duration: 1e3
                    }), void e.setData({
                        datas: []
                    });
                    for (var n = 0; n < s.data.getSearch.data.length; n++) s.data.getSearch.data[n].end_shooting = t.default.formatTimeTwo(s.data.getSearch.data[n].end_shooting, "Y-M-D h:m:s");
                    e.setData({
                        datas: s.data.getSearch.data,
                        current_page: s.data.getSearch.current_page,
                        last_page: s.data.getSearch.last_page
                    });
                } else wx.showToast({
                    title: s.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getSearchMore: function() {
        var e = this, s = a.getNetAddresss("plugin.auction.api.index.getAuctionData"), n = {
            keyword: e.data.keyword,
            status: this.data.status,
            auc_status: "",
            is_new: "",
            is_recommend: "",
            auctioneer_id: "",
            art: "getSearch",
            page: this.data.page
        };
        a._postNetWork({
            url: s,
            data: n,
            success: function(a) {
                var s = a.data;
                if (1 == s.result) {
                    if (0 == s.data.getSearch.data.length) return 1 == e.data.status ? wx.showToast({
                        title: "没有相关拍品",
                        icon: "none",
                        duration: 1e3
                    }) : 2 == e.data.status && wx.showToast({
                        title: "没有相关拍卖官",
                        icon: "none",
                        duration: 1e3
                    }), void e.setData({
                        datas: []
                    });
                    for (var n = 0; n < s.data.getSearch.data.length; n++) s.data.getSearch.data[n].end_shooting = t.default.formatTimeTwo(s.data.getSearch.data[n].end_shooting, "Y-M-D h:m:s");
                    var o = s.data.getSearch.data;
                    e.setData({
                        datas: e.data.datas.concat(o),
                        current_page: s.data.getSearch.current_page,
                        last_page: s.data.getSearch.last_page
                    });
                } else wx.showToast({
                    title: s.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});